package com.web.dao;

import com.web.domain.ListVo;
import com.web.entity.CurrencyDetailsBZJBean;
import com.web.entity.CurrencyDetailsBean;
import com.web.entity.CurrencyRecord;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface CurrencyRecordMapper {
    @Delete({
        "delete from TB_APP_CURRENCY_RECORD",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into TB_APP_CURRENCY_RECORD (currency_deduction, currency_balance, ",
        "use_type, sender, ",
        "receiver, is_vip_expenditure, ",
        "create_time, modify_time)",
        "values (#{currencyDeduction,jdbcType=INTEGER}, #{currencyBalance,jdbcType=INTEGER}, ",
        "#{useType,jdbcType=INTEGER}, #{sender,jdbcType=VARCHAR}, ",
        "#{receiver,jdbcType=VARCHAR}, #{isVipExpenditure,jdbcType=INTEGER}, ",
        "#{createTime,jdbcType=TIMESTAMP}, #{modifyTime,jdbcType=TIMESTAMP})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Integer.class)
    int insert(CurrencyRecord record);

    int insertSelective(CurrencyRecord record);

    @Select({
        "select",
        "id, currency_deduction, currency_balance, use_type, sender, receiver, is_vip_expenditure, ",
        "create_time, modify_time",
        "from TB_APP_CURRENCY_RECORD",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    CurrencyRecord selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(CurrencyRecord record);

    @Update({
        "update TB_APP_CURRENCY_RECORD",
        "set currency_deduction = #{currencyDeduction,jdbcType=INTEGER},",
          "currency_balance = #{currencyBalance,jdbcType=INTEGER},",
          "use_type = #{useType,jdbcType=INTEGER},",
          "sender = #{sender,jdbcType=VARCHAR},",
          "receiver = #{receiver,jdbcType=VARCHAR},",
          "is_vip_expenditure = #{isVipExpenditure,jdbcType=INTEGER},",
          "create_time = #{createTime,jdbcType=TIMESTAMP},",
          "modify_time = #{modifyTime,jdbcType=TIMESTAMP}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(CurrencyRecord record);

    List<CurrencyDetailsBean> getCurrencyDetails(@Param("userId") String userId);

    List<CurrencyDetailsBZJBean> getCurrencyDetailsBZJ(@Param("userId") String userId);
}